home *** CD-ROM | disk | FTP | other *** search
-
- /*
- File: OvalLibrary.c
-
- Contains: graphics libraries - oval routines
-
- Written by: Cary Clark, Georgiann Delaney, Michael Fairman, Dave Good, Robert Johnson, Keith McGreggor, Oliver Steele, David Van Brink, Chris Yerga
-
- Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <1> 1/9/95 JD First checked in.
- */
-
- #include "GraphicsLibraries.h"
-
- #define FRACROOT2less1 444758426
-
- /*
- * ovalPath must be 18 fixed numbers. Set the gxPath
- * to the oval described in theOval.
- */
- static void OvalPath(Fixed ovalPath[], const gxRectangle *r)
- {
- register Fixed *pointWalker;
- register Fixed cx, cy, h, v;
-
- cx = (r->left + r->right)/2;
- cy = (r->top + r->bottom)/2;
- h = FractMultiply(FRACROOT2less1, (r->right - r->left)/2);
- v = FractMultiply(FRACROOT2less1, (r->bottom - r->top)/2);
- pointWalker = ovalPath; /* start at the beginning */
- *pointWalker++ = 8; /* eight points */
- *pointWalker++ = 0xFF000000; /* all points off gxCurve */
- /*
- * Start on the left edge, go up and around
- */
- *pointWalker++ = r->left; *pointWalker++ = cy - v;
- *pointWalker++ = cx - h; *pointWalker++ = r->top;
- *pointWalker++ = cx + h; *pointWalker++ = r->top;
- *pointWalker++ = r->right; *pointWalker++ = cy - v;
-
- *pointWalker++ = r->right; *pointWalker++ = cy + v;
- *pointWalker++ = cx + h; *pointWalker++ = r->bottom;
- *pointWalker++ = cx - h; *pointWalker++ = r->bottom;
- *pointWalker++ = r->left; *pointWalker++ = cy + v;
- }
-
-
- gxShape NewOval(const gxRectangle *ovalData)
- {
- Fixed ovalPath[18]; /* 1 vector count, 1 control bit long, 8 points */
-
- NilParamReturnNil(ovalData);
- OvalPath(ovalPath, ovalData);
- return NewPath((gxPath *) ovalPath);
- }
-
- void SetOval(gxShape s, const gxRectangle *ovalData)
- {
- Fixed ovalPath[18];
-
- NilShapeReturn(s);
- NilParamReturn(ovalData);
-
- OvalPath(ovalPath, ovalData);
- SetPath(s, 0, (gxPath *)ovalPath);
- }
-
-
- void DrawOval(const gxRectangle *ovalData, gxShapeFill geom)
- {
- register gxShape ovalShape;
-
- NilParamReturn(ovalData);
- ovalShape = NewOval(ovalData);
- GXSetShapeFill(ovalShape, geom);
- GXDrawShape(ovalShape);
- GXDisposeShape(ovalShape);
- }
-